<?php

namespace App\ZhCN\Api;

if (!defined('IN_PX'))
    exit;

use App\Repository;
use App\Service;
use Phoenix\Support\MsgHelper;
use Phoenix\Log\Log4p as logger;

class ContactForm {

    private function __RestController() {}

    private function __Route($value = '/api') {}

    protected function __Inject($session, Repository\ContactForm $contactForm,Service\Mail $servMail) {}

    /**
     * 首页联系表单接品
     * @return array
     */
    public function contactForm() {
        $_model['email'] = 'eric.han@lumexsys.com';
        $content = "姓名:".$_POST['name']." 电话:".$_POST['phone']."<br>"
            .'E-mail:'.$_POST['email'].' 公司:'.$_POST['company'].'<br>'
            .'职位:'.$_POST['message'];
        $title = '路美思联系我们';
        $flag = $this->contactForm->save($_POST);
        $result = $this->servMail->send($_model['email'], $title, $content);
        if ($result && $flag) {
            return MsgHelper::err(0);
        } else {
            return  MsgHelper::err(10003, '系统繁忙!');
        }
    }
}
